package com.ruix.app.ui.stratum.lesson;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.ruix.app.R;
import com.ruix.app.ui.base.BaseActivity;
import com.ruix.app.widget.CommonTitleBar;

/**
 * Created by hadexs on 2017/5/10.
 */

public class AskQuestionActivity extends BaseActivity{

    public static Intent getInstent(Context contxt){
        Intent intent = new Intent(contxt,AskQuestionActivity.class);
        return intent;
    }


    private  EditText editText;

    @Override
    protected int loadViewLayout() {
        return R.layout.activity_ask_question;
    }

    @Override
    protected void initView() {
        setTitle("提出问题");

        CommonTitleBar titleBar = getTitleBar();
        TextView titleBarRightBtn = titleBar.getRightBtn();
        titleBarRightBtn.setText("发送");
        titleBarRightBtn.setTextColor(getResources().getColor(R.color.green));
        titleBarRightBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sendQuestion();
            }
        });

        ImageView leftBackBtn = titleBar.getLeftBackBtn();
        leftBackBtn.setImageResource(R.drawable.close);
         editText = (EditText) findViewById(R.id.et_question);

    }


    private void sendQuestion(){
        String question = editText.getText().toString().trim();
        if (TextUtils.isEmpty(question)){
            showErrorTip("请输入问题");
            return;
        }
        Intent intent = new Intent();
        intent.putExtra("question",question);
        setResult(RESULT_OK,intent);
        finish();
    }

    @Override
    protected void initLocalData() {

    }

    @Override
    protected void initListener() {

    }
}
